<template>
    <div style="padding-bottom: 12px;background-color: #fff;">
        <div class=""
            style="display: flex;flex-direction: row;align-items: center;padding: 12px;background-color: #FFFFFF;justify-content: space-between;"
            v-if="canback">
            <div class="" @click="popBack()">
                <i class="iconfont icon-arrow-left" style="font-size: 16px;font-weight: bold;"></i>
                <span style="font-size: 16px;">返回</span>
            </div>
        </div>
        <!-- 头像 -->
        <div style="display: flex;padding: 0 12px;align-items: center;" v-if="canback">
            <van-image round width="64px" height="64px" :src="data.headUrl" />
            <div style="font-size: 16px;margin-left: 12px;">{{data.nickName}}</div>
        </div>
        <expand-data-cell title="详细资料" :items="detailData" />
        <expand-data-cell title="国籍所在地" :items="countryData" />
        <expand-data-cell title="紧急联系人" :items="familyData" />
        <expand-data-cell title="就读大学" :items="collegeData" />
        <expand-data-cell title="英语登记" :items="englishData" />
        <expand-data-cell title="纸质成绩单寄送地址" :items="obj" :key="idx" v-for="(obj,idx) in postData" />
        <expand-data-cell title="电子成绩单寄送" :items="obj" :key="idx" v-for="(obj,idx) in emailData" />
        <expand-data-cell title="跟进频率" :items="noticeData" />
    </div>
</template>

<script>
    import { readStudentId } from "../../api/person";
    export default {
        props: ["data"],
        name: "detailinfo",
        components: {
            "expand-data-cell": () =>
                import("@/components/expand-data-cell/expand-data-cell.vue"),
        },
        data() {
            return {
                detailData: [
                    { label: "First Name" },
                    { label: "Last Name" },
                    { label: "出生日期" },
                    { label: "性别" },
                    { label: "证件类型" },
                    { label: "证件号" },
                    { label: "出生地" },
                    { label: "国籍" },
                    { label: "联系地址" },
                    { label: "邮编" },
                    { label: "签证类型" },
                    { label: "电话" },
                    { label: "海外电话" },
                    { label: "EMail" },
                    { label: "备用Email" },
                    { label: "最高学历" },
                    { label: "创建人" },
                    { label: "创建时间" },
                ],
                countryData: [
                    { label: "开始居住时间" },
                    { label: "国家" },
                    { label: "地址" },
                    { label: "邮编" },
                ],
                familyData: [
                    { label: "姓名" },
                    { label: "关系" },
                    { label: "使用语言" },
                    { label: "使用语言" },
                ],
                collegeData: [
                    { label: "国家" },
                    { label: "城市" },
                    { label: "学校名" },
                    { label: "入学时间" },
                    { label: "毕业时间" },
                    { label: "以修学分" },
                    { label: "就读专业" },
                    { label: "辅修专业" },
                    { label: "目前GPA" },
                    { label: "大学毕业时间" },
                ],
                englishData: [
                    { label: "英语等级" },
                    { label: "考试分数" },
                    { label: "考试时间" },
                ],
                postData: [],
                emailData: [],
                noticeData: [
                    { label: "提醒人" },
                    { label: "提醒方式" },
                    { label: "跟进周期" },
                ],
                id: undefined,
                canback: false,
            };
        },
        mounted() {
            if (this.data == undefined) {
                let { id } = this.$route.query;
                this.netReadStudent(id);
                this.canback = true;
            } else {
                this.setupView(this.data);
                this.canback = false;
            }
        },
        methods: {
            netReadStudent(id) {
                let self = this;
                let fi = {
                    id,
                };
                readStudentId(fi).then((res) => {
                    let { code, msg, data } = res;
                    if (code == 200) {
                        self.data = data;
                        self.setupView(data);
                    } else {
                        self.$toast(msg);
                    }
                });
            },

            setupView(data) {
                //   let data = {
                //     actHead: "string",
                //     actHeadCode: 0,
                //     addDetail: "string",
                //     asdHead: "string",
                //     asdHeadCode: 0,
                //     backEmail: "string",
                //     birthAdd: "string",
                //     chnName: "string",
                //     chnSource: "渠道来源111",
                //     city: "string",
                //     colAdd: "string",
                //     colBtime: "2021-11-08T06:04:02.851Z",
                //     colCredit: 0,
                //     colCty: "string",
                //     colDegree: "string",
                //     colEduCredit: 0,
                //     colEtime: "2021-11-08T06:04:02.851Z",
                //     colMinorPro: "string",
                //     colName: "string",
                //     colPga: "string",
                //     colReadPro: "string",
                //     country: "string",
                //     createBy: "string",
                //     createTime: "2021-11-08T06:04:02.851Z",
                //     dateBirth: "2021-11-08T06:04:02.851Z",
                //     deleted: 0,
                //     eduType: "string",
                //     email: "string",
                //     engLevel: "string",
                //     engScore: 0,
                //     engTime: "2021-11-08T06:04:02.851Z",
                //     followRate: 0,
                //     givenName: "string",
                //     headUrl: "string",
                //     hschBtime: "2021-11-08T06:04:02.851Z",
                //     hschCity: "string",
                //     hschCty: "string",
                //     hschEtime: "2021-11-08T06:04:02.851Z",
                //     hschlName: "string",
                //     id: 0,
                //     interDegree: "string",
                //     liveBtime: "2021-11-08T06:04:02.851Z",
                //     livePostCode: "string",
                //     localPhone: "string",
                //     nationality: "string",
                //     openid: "string",
                //     osPhone: "string",
                //     paperNum: "string",
                //     papersType: 0,
                //     postalCode: "string",
                //     province: "string",
                //     purpose:
                //       '[ { "id": "新增默认传0", "school": "意向学校1", "project": "意向项目", "course": "意向课程", "authStatus": "课程认证状态", "认证截图地址": "authUrl", "failCause": "失败原因" }, { "id": "新增默认传0", "school": "意向学校2", "project": "意向项目", "course": "意向课程", "authStatus": "课程认证状态", "认证截图地址": "authUrl", "failCause": "失败原因" } ]',
                //     relaAdd: "string",
                //     remark: "string",
                //     saleHead: "string",
                //     saleHeadCode: 0,
                //     sex: 0,
                //     stuName: "szw",
                //     stuPurposes: [
                //       {
                //         authStatus: "string",
                //         authUrl: "string",
                //         buspId: 0,
                //         course: "string",
                //         createBy: "string",
                //         createTime: "2021-11-08T06:04:02.851Z",
                //         deleted: 0,
                //         failCause: "string",
                //         id: 0,
                //         project: "string",
                //         remark: "string",
                //         school: "string",
                //         updateBy: "string",
                //         updateTime: "2021-11-08T06:04:02.851Z",
                //       },
                //     ],
                //     stuReminds: [
                //       {
                //         buspId: 0,
                //         createBy: "string",
                //         createTime: "2021-11-08T06:04:02.851Z",
                //         deleted: 0,
                //         id: 0,
                //         nextTime: "2021-11-08T06:04:02.851Z",
                //         remark: "string",
                //         remindRate: 0,
                //         remindType: "string",
                //         updateBy: "string",
                //         updateTime: "2021-11-08T06:04:02.851Z",
                //       },
                //     ],
                //     stuTranscriptAdds: [
                //       {
                //         addDetail: "string",
                //         backEmail: "string",
                //         buspId: 0,
                //         city: "string",
                //         county: "string",
                //         createBy: "string",
                //         createTime: "2021-11-08T06:04:02.851Z",
                //         curDetail: "string",
                //         curUrl: "string",
                //         deleted: 0,
                //         email: "string",
                //         id: 0,
                //         postalCode: "string",
                //         province: "string",
                //         recAdd: "string",
                //         recName: "string",
                //         recPhone: "string",
                //         remark: "string",
                //         semester: "string",
                //         trackName: "string",
                //         trackNum: "string",
                //         trackStatus: 0,
                //         tranType: 0,
                //         updateBy: "string",
                //         updateTime: "2021-11-08T06:04:02.851Z",
                //       },
                //     ],
                //     surname: "string",
                //     transcriptAdd: "string",
                //     unionid: "string",
                //     updateBy: "string",
                //     updateTime: "2021-11-08T06:04:02.851Z",
                //     urgEmail: "string",
                //     urgLag: "string",
                //     urgName: "string",
                //     urgPhone: "string",
                //     urgRelative: "string",
                //     visaType: "string",
                //     wxUserId: "string",
                //   };

                this.detailData = [
                    { label: "First Name", value: data["surname"] },
                    { label: "Last Name", value: data["givenName"] },
                    { label: "出生日期", value: data["dateBirth"] },
                    { label: "性别", value: data["sex"] == 1 ? "男" : "女" },
                    {
                        label: "证件类型",
                        value: data["papersType"] == 1 ? "身份证" : "护照号",
                    }, //1:身份证2:护照号
                    { label: "证件号", value: data["paperNum"] },
                    { label: "出生地", value: data["birthAdd"] },
                    { label: "国籍", value: data["nationality"] },
                    { label: "联系地址", value: data["relaAdd"] },
                    { label: "邮编", value: data["postalCode"] },
                    { label: "签证类型", value: data["visaType"] },
                    { label: "电话", value: data["localPhone"] },
                    { label: "海外电话", value: data["osPhone"] },
                    { label: "Email", value: data["email"] },
                    { label: "备用Email", value: data["backEmail"] },
                    { label: "最高学历", value: data["eduType"] },
                    { label: "创建人", value: data["createBy"] },
                    { label: "创建时间", value: data["createTime"] },
                ];
                this.countryData = [
                    { label: "开始居住时间", value: data["liveBtime"] },
                    { label: "国家", value: data["nationality"] },
                    { label: "地址", value: data["addDetail"] },
                    { label: "邮编", value: data["livePostCode"] },
                ];
                this.familyData = [
                    { label: "姓名", value: data["urgName"] },
                    { label: "关系", value: data["urgRelative"] },
                    { label: "使用语言", value: data["urgLag"] },
                ];

                this.collegeData = [
                    { label: "国家", value: data["colCty"] },
                    { label: "学校名", value: data["colName"] },
                    { label: "入学时间", value: data["colBtime"] },
                    { label: "毕业时间", value: data["colEtime"] },
                    { label: "已修学分", value: data["colCredit"] },
                    { label: "就读专业", value: data["colReadPro"] },
                    { label: "辅修专业", value: data["colMinorPro"] },
                    { label: "目前PGA", value: data["colPga"] },
                ];
                this.englishData = [
                    { label: "英语等级", value: data["engLevel"] },
                    { label: "考试分数", value: data["engScore"] },
                    { label: "考试时间", value: data["engTime"] },
                ];

                //地址类型:1纸质2电子
                let transcriptAdd = data["transcriptAdd"];
                //   let transcriptAdd =
                // '[{"id":"新增默认传","postalCode":"邮编","recName":"收件人1","recPhone":"收件人电话","recAdd":"收件人地址","tranType":"2","email":"邮箱","backEmail":"备用邮箱"}]';
                let transcriptAdds = JSON.parse(transcriptAdd);
                for (let obj of transcriptAdds) {
                    let tranType = obj["tranType"];
                    if (tranType == "1") {
                        let post = [
                            { label: "收件人", value: obj["recName"] },
                            { label: "收件人电话", value: obj["recPhone"] },
                            { label: "收件人地址", value: obj["recAdd"] },
                            { label: "邮编", value: obj["postalCode"] },
                        ];
                        this.postData.push(post);
                    } else {
                        let email = [
                            { label: "收件人", value: obj["recName"] },
                            { label: "邮箱", value: obj["email"] },
                            { label: "备用邮箱", value: obj["backEmail"] },
                        ];
                        this.emailData.push(email);
                    }
                }
            },

            popBack() {
                this.$router.back({});
            },
        },
    };
</script>

<style>
</style>